home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / CDTools / MUIRexx / demos / MUIRexxBuild / comm.rexx < prev    next >
OS/2 REXX Batch file  |  1997-04-19  |  6KB  |  201 lines

  1. /* */
  2. options results
  3. parse arg comm
  4.  
  5. /* Attribute TAG ID definitions */
  6.  
  7. List_Active =                     0x8042391c /* V4  isg LONG              */
  8. ASLFR_DrawersOnly =               0x8008002f
  9. ASLFR_InitialDrawer =             0x80080009
  10.  
  11. TRUE = 1
  12. List_Insert_Bottom = -3
  13.  
  14. address BUILD
  15.  
  16. select
  17.     when comm = 'LEFT' then do
  18.         list ID DLST ATTRS List_Active
  19.         dpos = result
  20.         list ID DLST POS dpos
  21.         gobj = result
  22.         parse var gobj obj .
  23.         nspc = pos(obj,gobj)-1
  24.         if nspc > 0 then do
  25.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc-1)
  26.         end
  27.     end
  28.     when comm = 'RIGHT' then do
  29.         list ID DLST ATTRS List_Active
  30.         dpos = result
  31.         list ID DLST POS dpos
  32.         gobj = result
  33.         parse var gobj obj .
  34.         nspc = pos(obj,gobj)-1
  35.         if nspc >= 0 then do
  36.             list ID DLST POS dpos STRING '='||insert(strip(gobj),'',nspc+1)
  37.         end
  38.     end
  39.     when comm = 'COPY' then do
  40.         list ID DLST ATTRS List_Active
  41.         dpos = result
  42.         i = 0
  43.         do forever
  44.             list ID DLST
  45.             if result = '' then break
  46.             i = i + 1
  47.             line.i = result
  48.         end
  49.         do n = 1 to i
  50.             list ID DLST INSERT POS dpos+n STRING line.n
  51.         end
  52.     end
  53.     when comm = 'CREATE' then do
  54.         string ID APRT
  55.         aport = upper(result)
  56.         if aport = '' then exit
  57.         if show('ports',aport) then do
  58.             address value aport
  59.             quit
  60.             address
  61.             do while show('ports',aport)
  62.             end
  63.         end
  64.         call writemacro 't:tmp'
  65.         address command 'run >nil: MUIRexx:MUIRexx PORT 'aport' t:tmp'
  66.         address command 'delete t:tmp.rexx QUIET'
  67.     end
  68.     when comm = 'CLOSE' then do
  69.         string ID APRT
  70.         aport =  upper(result)
  71.         if show('ports',aport) then do
  72.             address value aport
  73.             quit
  74.             address
  75.         end
  76.     end
  77.     when comm = 'NEW' then do
  78.         list ID DLST STRING
  79.         list ID VLST STRING
  80.         string ID APRT CONTENT 'TEST'
  81.         setvar objlist
  82.     end
  83.     when comm = 'SAVE' then do
  84.         getvar directory
  85.         aslrequest ID BWIN TITLE '"Select Directory"' ATTRS ASLFR_DrawersOnly TRUE ASLFR_InitialDrawer result
  86.         if rc = 0 then do
  87.             dir = result
  88.             if (~exists(dir)) then exit
  89.             setvar directory dir
  90.             if lastpos('/',dir) ~= length(dir) then do
  91.                 if lastpos(':',dir) ~= length(dir) then dir = dir'/'
  92.             end
  93.             string ID APRT
  94.             aport = result
  95.             name = dir||aport
  96.             call writemacro name
  97.             address command 'copy build:build.info 'name'.info QUIET'
  98.         end
  99.     end
  100.     when comm = 'SAVEAS' then do
  101.         getvar directory
  102.         aslrequest ID BWIN TITLE '"Select File"' ATTRS ASLFR_InitialDrawer result
  103.         if rc = 0 then do
  104.             file = result
  105.             if lastpos('/',file) ~= 0 then dir = substr(file,1,lastpos('/',file)-1)
  106.             else dir = substr(file,1,lastpos(':',file))
  107.             setvar directory dir
  108.             call writemacro file
  109.         end
  110.     end
  111.     when comm = 'READ' then do
  112.         getvar directory
  113.         aslrequest ID BWIN TITLE '"Select File"' ATTRS ASLFR_InitialDrawer result
  114.         if rc = 0 then do
  115.             name = result
  116.             if (~exists(name)) then exit
  117.             if lastpos('/',name) ~= 0 then dir = substr(name,1,lastpos('/',name)-1)
  118.             else dir = substr(name,1,lastpos(':',name))
  119.             setvar objlist
  120.             setvar directory dir
  121.             list ID DLST STRING
  122.             list ID VLST STRING
  123.             call open('file',name,'R')
  124.  
  125.             aport = ''
  126.             do while ~eof('file')
  127.                 line = readln('file')
  128.                 if strip(line) = '' then iterate
  129.                 if index(strip(line),'/*') = 1 then iterate
  130.                 if index(line,'=') > 0 then do
  131.                     parse var line vname op value .
  132.                     if strip(op) = '=' then do
  133.                         list ID VLST INSERT POS List_Insert_Bottom STRING strip(vname)' = 'strip(value)
  134.                         iterate
  135.                     end
  136.                 end
  137.                 if aport = '' then do
  138.                     if index(line,'address') = 1 then do
  139.                         parse var line 'address 'pname comm
  140.                         if comm = '' then do
  141.                             aport = pname
  142.                             string ID APRT CONTENT aport
  143.                             iterate
  144.                         end
  145.                     end
  146.                 end
  147.                 parse var line obj args
  148.                 if index(strip(args),'ID') = 1 then do
  149.                     parse var args 'ID 'gid args
  150.                     call addobj(gid)
  151.                 end
  152.                 list ID DLST INSERT POS List_Insert_Bottom STRING '='||line
  153.             end
  154.             call close('file')
  155.         end
  156.     end
  157.     otherwise nop
  158. end
  159.  
  160. exit
  161.  
  162. writemacro: procedure
  163. parse arg name
  164.  
  165. string ID APRT
  166. aport = result
  167. if index(name,'.rexx') = 0 then name = name'.rexx'
  168. call open('file',name,'W')
  169. call writeln('file','/* Application created by MUIBuild */')
  170. call writeln('file','')
  171. call writeln('file','address 'aport)
  172. call writeln('file','')
  173. i = 0
  174. do forever
  175.     list ID VLST POS i
  176.     line = result
  177.     if line = '' then break
  178.     call writeln('file',line)
  179.     i = i + 1
  180. end
  181. call writeln('file','')
  182. i = 0
  183. do forever
  184.     list ID DLST POS i
  185.     line = result
  186.     if line = '' then break
  187.     call writeln('file',line)
  188.     i = i + 1
  189. end
  190. call close('file')
  191. return
  192.  
  193. addobj: procedure
  194. parse arg obj
  195.  
  196. getvar objlist
  197. objects = result
  198. if index(objects,obj) = 0 then objects = objects||obj||','
  199. setvar objlist objects
  200. return
  201.